// 快速浮动消息
let sysMessagePanel
let floatTimer
function createSysMessagePanel () {
  if (sysMessagePanel) return
  const el = document.createElement('div')
  el.className = 'float-message'
  document.body.appendChild(el)
  sysMessagePanel = el
}

function quickMessage (message, type) {
  if (!sysMessagePanel) createSysMessagePanel()
  sysMessagePanel.innerText = message
  const cls = 'float-message active ' + type
  sysMessagePanel.className = cls
  if (floatTimer) clearTimeout(floatTimer)
  floatTimer = setTimeout(() => {
    sysMessagePanel.className = 'float-message'
  }, 2500)
}

if (document.body) {
  createSysMessagePanel()
} else {
  window.addEventListener('load', function () {
    createSysMessagePanel()
  })
}
export default function showMessage (message, type) {
  quickMessage(message, type || 'info')
}
